// 封装文章相关操作
import ajax from '../utils/request.js'
/**
 * 获取文章列表
 * @param {*} channelId 频道id
 * @param {*} timestamp 时间戳
 */
export const getArticle = (channelId, timestamp) => {
  return ajax({
    url: '/app/v1_1/articles',
    method: 'GET',
    params: {
      channel_id: channelId,
      timestamp: timestamp,
      with_top: 1
    }
  })
}
/**
 * 不喜欢文章
 * @param {*} articleId 文章id
 */
export const uninterested = (articleId) => {
  return ajax({
    url: '/app/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: articleId
    }
  })
}
/**
 * 用户举报功能
 * @param {*} articleId 文章id
 * @param {*} type 举报类型
 */
export const userReport = (articleId, type) => {
  return ajax({
    url: '/app/v1_0/article/reports',
    method: 'POST',
    data: {
      target: articleId,
      type
    }
  })
}
/**
 * 获取文章详细信息
 * @param {*} articleId
 */
export const getArticleList = (articleId) => {
  return ajax({
    url: '/app/v1_0/articles/' + articleId,
    method: 'GET'
  })
}
export const likeArticle = (articleId) => {
  return ajax({
    url: '/app/v1_0/article/likings',
    method: 'POST',
    data: {
      target: articleId
    }
  })
}

export const concleLike = (articleId) => {
  return ajax({
    url: '/app/v1_0/article/likings/' + articleId,
    method: 'DELETE'
  })
}
/**
 * 对文章不喜欢
 * @param {*} articleId
 */
export const disLike = (articleId) => {
  return ajax({
    url: '/app/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: articleId
    }
  })
}
/**
 * 取消对文章不喜欢
 * @param {*} articleId
 */
export const concleDisLike = (articleId) => {
  return ajax({
    url: '/app/v1_0/article/dislikes/' + articleId,
    method: 'DELETE'
  })
}
